package com.lc.admin.web;

import com.lc.admin.base.ResponseResult;
import com.lc.admin.dto.LoginDto;
import com.lc.admin.service.UserService;
import com.lc.admin.vo.UserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@Api(tags="后台登录接口")
@RequestMapping("/security")
@RestController
public class LoginWeb {

    @Autowired
    UserService userService;

//    @ApiOperation("后台登录接口")
    @PostMapping("/login")
    public ResponseResult login(@RequestBody LoginDto loginDto){
        String name = Thread.currentThread().getName();
        System.out.println("控制器线程名：" + name);
        try {
            UserVo userVo = userService.login(loginDto);
            return ResponseResult.success(userVo);
        } catch (Exception e) {
           return ResponseResult.error(e.getMessage());
        }
    }
}
